#pragma mark -
#pragma mark Configuring the View Rotation Settings

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{	
	static int count = 0;
	
	NSLog(@"Rot Count: %d", ++count);
	
	BOOL shouldRotate = YES;
	
	return shouldRotate;
}

// ToDo: Handle fixed layout by showing an inform page view
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

	if (isFixedLayout) 
	{
    // ToDo: Simplify logic
    // If isLandscapeMode, we will rotate to portrait mode
		if (isLandscapeMode)
		{
			if ([channelData.orientationStr isEqualToString:@"l"]) 
			{
				shouldShowInform = YES;
			}
		}
		else
		{
			if ([channelData.orientationStr isEqualToString:@"p"]) 
			{
				shouldShowInform = YES;
			}
		}
	}
    

    // Unify get width and height
    int width, height;
    if (isLandscapeMode)
    {
        width = SCREEN_WIDTH_PORTRAIT;
        height = PAGE_HEIGHT_PORTRAIT;
    }
    else 
    {
        width = SCREEN_WIDTH_LANDSCAPE;
        height = PAGE_HEIGHT_LANDSCAPE;
    }
    
    [self setupInformView:isLandscapeMode];
    contentScrollView.frame = CGRectMake(0, kTopPanelHeight, width, height);
    contentScrollView.contentSize = CGSizeMake(width * 3, height);
    [self rotateContentViewControllers];
}


- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
//- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{	
	// Note: Orientation changed, so if in landscape, change to portrait
	int width, height;
	if (isLandscapeMode)
	{
		width = SCREEN_WIDTH_PORTRAIT;
		height = PAGE_HEIGHT_PORTRAIT;
		isLandscapeMode = NO;
	}
	else
	{
		width = SCREEN_WIDTH_LANDSCAPE;
		height = PAGE_HEIGHT_LANDSCAPE;
		isLandscapeMode = YES;
	}

	[contentScrollView setContentOffset:CGPointMake(width, 0) animated:NO];
	bottomPanelView.frame = CGRectMake(0, height+kTopPanelHeight-kBottomPanelHeight, width, kBottomPanelHeight);
	[topJumpView setPreviewPanelFrame:isLandscapeMode];
	[botArtGroupJumpView setPreviewPanelFrame:isLandscapeMode];
}

// ToDo: Call this method in the appropriate rotation delegate
- (void)setupInformView:(BOOL)isLandscape
{
    int width = 0, height = 0;
    if (isLandscape)
    {
        width = SCREEN_WIDTH_PORTRAIT;
        height = SCREEN_HEIGHT_PORTRAIT;
    }
    else 
    {
        width = SCREEN_WIDTH_LANDSCAPE;
        height = SCREEN_HEIGHT_LANDSCAPE;
    }
	
    if (shouldShowInform) 
	{
		// ToDo: Init informView in the beginning
		UIView *informView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
		informView.backgroundColor = [UIColor redColor];
		informView.tag = 12345;
		[self.view addSubview:informView];
		[informView release];
		shouldShowInform = NO;
	}
	else 
	{
		UIView *informView = [self.view viewWithTag:12345];
		[informView removeFromSuperview];
	}
}
